<template>
<div>
  <!-- 面包屑导航 -->
  <el-breadcrumb separator="/">
    <el-breadcrumb-item :to="{ path: '/yreay/' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item :to="{ path: '/yreay/index?pid='+project.id }">{{project.y_project_name}}</el-breadcrumb-item>
    <el-breadcrumb-item>{{plan ? plan.y_idea_name : ""}}</el-breadcrumb-item>
  </el-breadcrumb>

  <div style="margin-top: 5px;">

    <el-input placeholder="请输入内容-demo" v-model="input5" class="input-with-select" style="margin-bottom: 5px;">
      <template slot="prepend">
        <el-checkbox v-model="checked"></el-checkbox>
      </template>
      <el-button slot="append" icon="el-icon-edit"></el-button>
      <el-button slot="append" icon="el-icon-date"></el-button>
      <el-button slot="append" icon="el-icon-success"></el-button>
      <el-button slot="append" icon="el-icon-star-off"></el-button>
    </el-input>

    <div v-for="(item,index) in fordate">
      <el-input placeholder="请输入内容" :id="item.id" v-model="item.text" class="input-with-select" style="margin-bottom: 5px;" >
        <template slot="prepend">
          <el-checkbox v-model="checked"></el-checkbox>
        </template>
        <el-button slot="append" icon="el-icon-edit"></el-button>
        <el-button slot="append" icon="el-icon-date"></el-button>
        <el-button slot="append" icon="el-icon-circle-check-outline" @click.native="handleRightClick(item.id,index)"></el-button>
        <el-button slot="append" icon="el-icon-star-on"></el-button>
      </el-input>
    </div>

  </div>
</div>
</template>

<script>
  import {yprojectlist
    ,yplan
    ,savey
    ,findy
    ,dely
  } from "@/api/yready";

  export default {
    beforeRouteUpdate(to,from,next){
      console.log("beforeRouteUpdate,index.vue");
      this.getPlanData(to.query.pid);
      next();

    },
    created() {
      console.log("created,index.vue");
      this.init();
    },
    data() {
      console.log("data,index.vue");
      return {
        fordate: null,
        plan:{},
        project:{},
      };
    },
    methods: {
      init() {
        yprojectlist(this.$route.query)
          .then(res => {
            this.fordate = res.data;
          });
      },
      getPlanData(id){
        console.log(id,"index.vue,id")
        yplan({pid:id})
          .then(res => {
            this.fordate = res.data.listmyul1;
            if(res.data.project!== null)
            this.project = res.data.project;
            if(res.data.plan!== null)
            this.plan = res.data.plan;
          });
      },
      handleRightClick(id,index){
        console.log(id,"index.vue,handleRightClick");
        var param = {};
        param["row.id"] = id;
        param["row.y_idea_name"] = this.fordate[index].text;
        savey("idea",param);

      }
    }
  }

</script>

<style>
  .el-icon-date {
    color: #409EFF;
  }
</style>
